package com.tutu.user.mapper;


import com.tutu.commons.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


/**
 * @Program: SpringCloud
 * @Description:
 * @Author: JK.TuTu
 * @ @Version: 1.0
 * @Create: 2022-12-01 12:44
 **/
@Mapper
public interface UserMapper {
    @Select("select * from db_user where uid = #{uid}")
    User getUserById(int uid);


    /**
     * 获取用户可以借阅的图书数量
     */
    @Select("select ucount from db_user where uid=#{uid}")
    int getUserNum(@Param("uid") int uid);

    /**
     * 实现用户借阅图书
     */
    @Update("update db_user set ucount=#{ucount} where uid=#{uid}")
    boolean userBorrow(@Param("ucount") int count,@Param("uid") int uid);
}